<div class="title">
    <label>Các bài giảng Level {{$data['level']}}</label>
</div>
<div class="box-list overH">
    <ul>
        @forelse($data['lessons'] as $lesson)
        <?
        $flag = false;
        if ($data['in_progress'] == true || $lesson->pivot->is_public == 1)
            $flag = true;
        $link = $flag == true ? $lesson->generate_link() : "";
        ?>
        <li class="positionR">
            <div class="video">
                <a href="javascript:;" data-url="{{$link}}" class="check_access">
                    <img src="{{$lesson->thumbnail_link()}}" alt="{{$lesson->title}}"/>
                </a>
            </div>
            <div class="ct">
                <a href="javascript:;" data-url="{{$link}}" class="check_access">
                    <span class="colorRed">Bài {{$lesson->pivot->position}}:</span> {{$lesson->title}}
                </a>

                <div class="lineh color66">
                    {{str_limit(strip_tags($lesson->content),400,'...')}}
                </div>
            </div>
            <div class="number-lesson">
                @if($flag == true)
                {{$lesson->pivot->position}}
                @else
                <i class="fa fa-lock PdT3 MgL5"></i>
                @endif
            </div>
        </li>
        @empty
        @endforelse
    </ul>
    <!--    <div class="box-phantrang">-->
    <!--    </div>-->
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('.check_access').click(function () {
                var url = $(this).attr('data-url');
                if (url == '') {
                    $('#modal_alert_body').html('Bạn chưa đủ điều kiện để xem level này!');
                    $('#modal_alert').modal('show');

                } else
                    window.location.href = url
            }
        )
    });
</script>